#!/bin/bash
#SBATCH --job-name=MSE6701
#SBATCH --partition=64c512g
#SBATCH -N 1
#SBATCH --ntasks-per-node=4
#SBATCH --output=%j.out
#SBATCH --error=%j.err

. ../../0-tools/environment

module load intel-oneapi-compilers/2021.4.0
module load intel-oneapi-mpi/2021.4.0
module load intel-oneapi-mkl/2021.4.0

ulimit -s unlimited

# Step 1: structural relaxation
cp POSCAR POSCAR.orig
rm -rf INCAR KPOINTS
ln -s INCAR.relax INCAR
ln -s KPOINTS.01 KPOINTS

mpirun ${VASP}
mv OUTCAR OUTCAR.01

# Step 2: static for relaxed
rm -rf INCAR
ln -s INCAR.static INCAR
cp CONTCAR POSCAR

mpirun ${VASP}
mv OUTCAR OUTCAR.02

# Step 3: NSCF calculation (band structure, line mode)
rm -rf INCAR KPOINTS
ln -s INCAR.bs INCAR
ln -s KPOINTS.02 KPOINTS

mpirun ${VASP}
cp OUTCAR OUTCAR.03

# clean up
rm -rf CHG CONTCAR OSZICAR PBS.batch PCDAT XDATCAR REPORT
